<template>
  <div>
    <input type="text" v-model="inputValue">
    <p>5秒之后,显示输入的值为 {{oldValue}}</p>
  </div>
  <hr>
</template>

<script setup>
import { ref,watchEffect,watch } from 'vue'
const inputValue = ref('hello vue')
const oldValue = ref()
watchEffect(() => {
  setTimeout(() => {
    oldValue.value = inputValue.value
  },5000)
})
/* 监听inputValue的值,监听单个数据源 */
watch(inputValue,(inputValue,prevValue) =>{
  console.log(inputValue,prevValue);
})
/* 监听inputValue的值,监听多个数据源 */
watch([inputValue,oldValue],(inputValue,prevValue) =>{
  console.log(inputValue,prevValue);
})
</script>

<style scoped>

</style>